import { getRecommend } from "../../utils/api";
import { getHotList } from "../../utils/api";
import { getWeekNewBook } from "../../utils/api";
import { getRecentBook } from "../../utils/api";
import { getForYou } from "../../utils/api";
import { getCarousel } from "../../utils/api";
const recommend = {
  state() {
    return {
      // 编辑推荐
      getRecommendContent: "",
      // 热门榜单
      getHotList: "",
      // 本周新书
      getWeekNewBook: "",
      // 近期新书
      getRecentBook: "",
      // 专属为你推荐
      getForYou: "",
      // 首页轮播图
      getCarousel: "",
    };
  },
  mutations: {
    // 编辑推荐
    getRecommend(state, payload) {
      state.getRecommendContent = payload;
    },
    // 热门榜单
    getHotList(state, payload) {
      state.getHotList = payload;
    },
    // 本周新书
    getWeekNewBook(state, payload) {
      state.getWeekNewBook = payload;
    },
    // 近期新书
    getRecentBook(state, payload) {
      state.getRecentBook = payload;
    },
    // 专属为你推荐
    getForYou(state, payload) {
      state.getForYou = payload;
    },
    // 首页轮播图
    getCarousel(state, payload) {
      state.getCarousel = payload;
    },
  },
  actions: {
    // 编辑推荐
    async getRecommend({ commit }) {
      const res = await getRecommend();
      commit("getRecommend", res);
    },
    // 热门榜单
    async getHotList({ commit }) {
      const res = await getHotList();
      commit("getHotList", res);
    },
    // 本周新书
    async getWeekNewBook({ commit }) {
      const res = await getWeekNewBook();
      commit("getWeekNewBook", res);
    },
    // 近期新书
    async getRecentBook({ commit }) {
      const res = await getRecentBook();
      commit("getRecentBook", res);
    },
    // 专属为你推荐
    async getForYou({ commit }) {
      const res = await getForYou();
      commit("getForYou", res);
    },
    // 首页轮播图
    async getCarousel({ commit }) {
      const res = await getCarousel();
      commit("getCarousel", res);
    },
  },
};
export default recommend;
